const vm = new Vue({
    el: '#main',
    data: {
        ipt: '',
        inputAble: false,
        searchId: fxj.hasSearch() && fxj.getSearch().get('id'),
        cityName: fxj.hasSearch() ? decodeURI(fxj.getSearch().get('cityName')) : '目的地',
    },
    methods: {
        submit,
        inputTitle,
    },
});

if (fxj.deBug) {
    main();
}

function main() {
    fxj.fixLayout();
}

function apiready() {
    main();
}

function inputTitle(e) {
    if (!vm.searchId) {
        toast('请先选择目的地');
        e.target.blur();
    }
    else {
        vm.inputAble = true;
    }
}

async function submit() {
    goPage(`house_res_list.html`, {
        localData: {
            cityId: +vm.searchId,
        },
        data: {
            search: encodeURI(vm.ipt),
        },
    });
}

function doSearch(evt) {
    if (evt.keyCode === 13 || evt.code === 'Enter') {
        submit();
    }
}